enum MessageStatus {
  sending,
  sent,
  error,
  read
}

class ChatMessage {
  final String id;
  String text;
  final bool isUser;
  final DateTime timestamp;
  MessageStatus status;
  bool isStreaming;

  bool get canEdit => isUser && status != MessageStatus.sending;
  bool get canDelete => isUser || status == MessageStatus.error;

  ChatMessage({
    required this.id,
    required this.text,
    required this.isUser,
    DateTime? timestamp,
    required this.status,
    this.isStreaming = false,
  }) : timestamp = timestamp ?? DateTime.now();

  void appendText(String newText) {
    text += newText;
  }
}